package com.yaj.mesif.unil;

import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 接口返回工具类
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class RespBean {
    @ApiModelProperty(value = "成功时返回T，失败F时返回")
    private String code;
    @ApiModelProperty(value = "失败原因")
    private String message;
    @ApiModelProperty(value = "失败的数据")
    private Object data;

    /**
     * 返回成功结果
     * @param message
     * @return
     */
    public static RespBean success(String message){
        return new RespBean("00000",message,null);
    }

    public static RespBean success(Object obj){
        return new RespBean("00000","",obj);
    }

    /**
     *
     * @param message
     * @param obj
     * @return
     */
    public static RespBean success(String message,Object obj){
        return new RespBean("00000",message,obj);
    }

    /**
     * 失败返回结果
     * @param code
     * @param message
     * @return
     */
    public  static  RespBean error(String code,String message){
        return new RespBean(code,message,null);
    }

    /**
     *
     * @param code
     * @param message
     * @param obj
     * @return
     */
    public  static  RespBean error(String code,String message,Object obj){
        return new RespBean(code,message,obj);
    }
}
